import { ApprovalFlowApi } from '@/api'
import CommonModel from './common'

class ApprovalFlowModel extends CommonModel {
    static item = {
        // 公路名称
        roadCode: {
            value: null
        },
        // 起始桩号
        stakeStart: {
            value: null
        },
        // 终点桩号
        stakeEnd: {
            value: null
        },
        // 项目名称
        operatId: {
            value: null
        },
        // 检查内容
        content: {
            value: null
        },
        // 判断标准
        standard: {
            value: null
        }
    }

    constructor() {
        super()
        this.api = new ApprovalFlowApi()
    }
    transformContentList(arr) {
        if (!arr) {
            return
        }
        const contentList = []
        arr.forEach(list => {
            const obj = {}
            for (const key in list) {
                if (Object.hasOwnProperty.call(list, key)) {
                    const ele = list[key]
                    obj[key] = {
                        value: ele,
                        show: false
                    }
                }
            }
            contentList.push(obj)
        })
        return contentList
    }
    async approve(data) {
        const res = await this.api.approve(data)
        return res
    }
    async audit(data) {
        const res = await this.api.audit(data)
        return res
    }

    // 审批进度
    getApprovalDetail(data) {
        return this.api.getApprovalDetail(data)
    }
}

export default ApprovalFlowModel
